package com.example.libo.huihui.adapter;

import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.example.libo.huihui.R;
import com.example.libo.huihui.been.QingdanEntity;
import com.squareup.picasso.Picasso;

import java.util.ArrayList;

/**
 * Created by libo on 2017/1/10.
 */

public class HorizonImageAdapter extends RecyclerView.Adapter<HorizonImageAdapter.ViewHolder>{
    private ArrayList datas;
    private Context context;

    public HorizonImageAdapter(ArrayList datas, Context context){
        this.datas = datas;
        this.context = context;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_horizontal,parent,false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        QingdanEntity.DataBean.ItemsBean entity = (QingdanEntity.DataBean.ItemsBean) datas.get(position);
        Picasso.with(context).load(entity.getImage_url()).into(holder.imageView);
    }

    @Override
    public int getItemCount() {
        return datas.size();
    }

    public static class ViewHolder extends RecyclerView.ViewHolder{
        private ImageView imageView;

        public ViewHolder(View itemView) {
            super(itemView);
            imageView = (ImageView) itemView.findViewById(R.id.iv_horizontal);
        }
    }
}
